package org.ws.kardex.model;

/**
 *
 * @author gerardino
 */

import com.google.appengine.api.datastore.Key;
import java.util.LinkedList;
import java.util.List;
import javax.jdo.annotations.*;

@PersistenceCapable
public class Product {

    @PrimaryKey
    @Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
    private Key id;
    
    @Persistent
    private String name;
    
    @Persistent
    private String description;
    
    @Persistent
    private String measure;
    
    @Persistent
    private double remaining = 0.0;
    
    @Persistent
    private Inventory i;
    
    @Persistent(mappedBy="p")
    private List<Operation> operations = new LinkedList<Operation>();
    
    public Product(){
    }
    public Product(String name){
        this.name = name;
        this.description = "";
    }
    public Product(String name, String description){
        this.name = name;
        this.description = description;
    }
    public Product(String name, String description, int remaining){
        this.name = name;
        this.description = description;
        this.remaining = remaining;
    }
    
    public Key getId(){
        return this.id;
    }
    public String getName(){
        return this.name;
    }
    public void setName(String name){
        this.name = name;
    }
    public String getDescription(){
        return this.description;
    }
    public void setDescription(String description){
        this.description = description;
    }
    public String getMeasure(){
        return this.measure;
    }
    public void setMeasure(String measure){
        this.measure = measure;
    }
    public double getRemaining(){
        return this.remaining;
    }
    public void setRemaining(double remaining){
        this.remaining = remaining;
    }
    public Inventory getInventory(){
        return this.i;
    }
    public void setInventory(Inventory i){
        this.i = i;
    }
    public List<Operation> getOperations(){
        return this.operations;
    }
    public void setOperations(List<Operation> operations){
        this.operations.clear();
        this.operations.addAll(operations);
    }
}